module Slugable
  extend ActiveSupport::Concern

  included do
    validates_uniqueness_of :slug
    before_save :set_slug
  end

  def to_param
    slug
  end

  def set_slug
    self.slug = SecureRandom.hex(10) if self.slug.nil?
  end

  class_methods do
  end
end